OpenLayers.Layer.prototype.alwaysInRange = false;

OpenLayers.Layer.prototype.calculateInRange = function() {
    var inRange = false;

    if (this.alwaysInRange) {
        inRange = true;
    } else {
        if (this.map) {
        	
        	
        	//REGRA GEOSITE/////////////////////////////////////////////////
        	var me = this;
        	var parentChecked = function(group){
        		if(group){
        			if(!group.checked){
        				return false;
        			}else{
        				return parentChecked(group.parent);
        			}
        		}else{
        			return true;
        		}
        	};
        	
        	if(!me.scaleRanges || me.scaleRanges.length <= 0){
        		me.scaleRanges = [new MapService.Layer.ScaleRange()];
        	}
        	
        	me.currentScaleRange = null;
            if(me.scaleRanges && me.scaleRanges.length > 0){
            	var scale = me.map.getScale();
                for (var i = 0; i < me.scaleRanges.length; i++) {
                	inRange = ( (scale >= me.scaleRanges[i].minScale) && (scale <= me.scaleRanges[i].maxScale) && parentChecked(me.group));
                	if(inRange){
                		me.currentScaleRange = me.scaleRanges[i];
                		break;
                	}
                }
                return inRange;
            }
            //REGRA GEOSITE/////////////////////////////////////////////////
        	
            
        	
            var resolution = this.map.getResolution();
            inRange = ( (resolution >= this.minResolution) &&
                        (resolution <= this.maxResolution) );
        }
    }
    return inRange;
};